<?php
/**
 * 后台程序处理函数
 * @package WordPress
 * @subpackage wheatv
 */

/**
Customize meta box
**/
function wheatv_customize_meta_boxes() {
     remove_meta_box('postcustom','post','normal');
}
add_action('admin_init','wheatv_customize_meta_boxes');


/**
add statistics code to footer
**/
function wheatv_add_statistics_code() {
   if(get_option('statisticscode') <> ""){  
   echo stripslashes(get_option('statisticscode')); 
   } 
}
add_action('wp_footer', 'wheatv_add_statistics_code');

/**
add link-color css to footer
**/
function wheatv_add_linkcolor_css() {
   if(get_option('linkcolor') <> "" && get_option('defaultcolor')==''){ 
	   $return_css='<style type="text/css">'; 
	   $return_css.='a{color:'.stripslashes(get_option('linkcolor')).'}';
	   $return_css.='a:hover{color:'.stripslashes(get_option('hoverlinkcolor')).'}';
	   $return_css.='#header div.menu li a{color:'.stripslashes(get_option('navlinkcolor')).'}';
	   $return_css.='#header div.menu li a:hover{color:'.stripslashes(get_option('hovernavlinkcolor')).'}';
	   $return_css.='#header div.menu li.current-menu-item a{background:'.stripslashes(get_option('curnavlinkbg')).'}';
	   $return_css.='</style>'; 
	   echo $return_css; 
   } 
}
add_action('wp_head', 'wheatv_add_linkcolor_css');


/**
add code to header
**/
function wheatv_add_header_code() {
   if(get_option('headercode') <> ""){  
   echo stripslashes(get_option('headercode')); 
   } 
}
add_action('wp_head', 'wheatv_add_header_code');


/**
SEO setting
**/
function wheatv_seo_setting() {
   if(is_home()){
	  $keywords=get_option('keywords');
	  $description=get_option('description');
	}elseif(is_single()){
	  $page = get_page($post->ID);
	  $page_id = $page->ID;
	  $keywords=get_post_meta($page_id, 'post_keywords_value', true);
	  $description=get_post_meta($page_id, 'post_description_value', true);
	}elseif(is_page()){
	  $page = get_page($post->ID);
	  $page_id = $page->ID;
	  $keywords=get_post_meta($page_id, 'page_keywords_value', true);
	  $description=get_post_meta($page_id, 'page_description_value', true);
	}elseif(is_category()){
	  $keywords=single_cat_title('', false);
	  $description=strip_tags(category_description());
	}
	echo'<meta name="keywords" content="'.$keywords.'" />
         <meta name="description" content="'.$description.'" />';
}
add_action('wp_head', 'wheatv_seo_setting');

/**
Add page excerpt
**/
function wheatv_add_page_excerpt_meta_box() {
    add_meta_box( 'postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', 'page', 'normal', 'high' );
}
add_action( 'admin_menu', 'wheatv_add_page_excerpt_meta_box' );

/**
add items in profile;
**/
function wheatv_my_profile( $contactmethods ) {
    $contactmethods['telephone'] = '电话';
	$contactmethods['address'] = '地址';
    unset($contactmethods['aim']);
    unset($contactmethods['yim']);
    unset($contactmethods['jabber']);
    return $contactmethods;
}
//add_filter('user_contactmethods','wheatv_my_profile',10,1);

/**
Add widget in dashboard
**/
function wheatv_dashboard_widget_function() {
	echo '自定义内容于此';
}
function wheatv_add_dashboard_widgets() {
    wp_add_dashboard_widget('wheatv_dashboard_widget', '特别注意事项', 'wheatv_dashboard_widget_function');
}
//add_action('wp_dashboard_setup', 'wheatv_add_dashboard_widgets' );

?>